#define _CRT_SECURE_NO_WARNINGS 1
#include"SLT.h"
SL* middleNode(SL* head) {
	SL* slow = head;
	SL* fast = head;
	while (fast && fast->next)
	{
		slow = slow->next;
		fast = fast->next->next;
	}
	return slow;
}
SL* reverseSeList(SL* head) {
	SL* cur = head;
	SL* newHead = NULL;
	while (cur) {
		SL* next = cur->next;
		cur->next=newHead;
		newHead = cur;
		cur = next;
	}
	return newHead;
}
//SL* reverseSeList(SL* head) {
//	SL* n1 = NULL;
//	SL* n2 = head;
//	SL* n3 = head->next;
//	while (n2)
//	{
//		n2->next = n1;
//		n1 = n2;
//		n2 = n3;
//		if (n3)
//		{
//			n3 = n3->next;
//		}
//	}
//}
bool chkPadlindrome(SL* phead)
{
	SL* mid = middleNode(phead);
	SL* rmid = reverseSeList(mid);
	while (rmid && phead)
	{
		if (rmid->data != phead->data)
		{
			return false;
		}
		rmid = rmid->next;
		phead = phead->next;
	}
	return true;
}
int main()
{
	SL* plist=NULL;
	pushfrontSL(&plist, 1);
	pushfrontSL(&plist, 2);
	pushfrontSL(&plist, 1);
	pushfrontSL(&plist, 1);
	SLprint(plist);
	bool a=chkPadlindrome(plist);
	printf("%d", a);
	return 0;
}